// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var leftMenu = require("../leftMenu/leftMenu");
	var topMenu = require("../topMenu/topMenu");
	var footer = require("../footer/footer_main");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var css_claim = require("./claimManage.css");
	var html_create_claim_acceptance = require("./html_create_claim_acceptance.html");
	var html_create_claim_assessment = require("./html_create_claim_assessment.html");
	var html_create_claim_handle = require("./html_create_claim_handle.html");
	var html_create_claim_material = require("./html_create_claim_material.html");
	var html_create_claim_survey = require("./html_create_claim_survey.html");
	var html_create_corrective = require("./html_create_corrective.html");
	var html_create_report_case = require("./html_create_report_case.html");
	var html_create_settlement = require("./html_create_settlement.html");
	var html_finish_claim = require("./html_finish_claim.html");
	var html_close_claim = require("./html_close_claim.html");

	var html_claim_report_case_list = require("./html_claim_report_case_list.html");
	var html_claim_material_list = require("./html_claim_material_list.html");
	var html_claim_acceptance_list = require("./html_claim_acceptance_list.html");
	var html_claim_assessment_list = require("./html_claim_assessment_list.html");
	var html_claim_corrective_list = require("./html_claim_corrective_list.html");
	var html_claim_handle_list = require("./html_claim_handle_list.html");
	var html_claim_settlement_list = require("./html_claim_settlement_list.html");
	var html_claim_survey_list = require("./html_claim_survey_list.html");

	var html_settlement_detail = require("./html_settlement_detail.html");

	var databind = require("databind");
	var tools = require("tools");
	var financeId;
	var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var init = function(page) {
		if (page.params != null) {
			financeId = page.params.financeId;
		}
		footer.init();
		$("#footer").removeClass("none");
		leftMenu.init(8);
		topMenu.init(6);
		router.init();
		$(".table-section").removeClass("none");
		$(".footer").removeClass("none");
		var oData = {
			financeId : financeId,
			pageIndex: pageIndex,
			pageSize: pageSize,
			totalPageCount: totalPageCount,
			totalRecordCount: totalRecordCount,
			dateBegin: "",
			dateEnd: "",
			claimNumber: "",
			insuranceCompany: "",
			abnormalState: "",
			claimState: "",
			claimProcess: "",
		};
		$(".claimManage").parent().addClass("leftMenu-active");
		inquireClaimPageList(oData);
		initEvent();
	};
	var initEvent = function() {
		$("#claimManage").on("click", "#claimManageSearch", function() {
			pageIndex = 1;
			pageSize = 10;
			totalPageCount = 1;
			totalRecordCount = 0; //分页初始化			
			var oData = {
				pageIndex: pageIndex,
				pageSize: pageSize,
				totalPageCount: totalPageCount,
				totalRecordCount: totalRecordCount,
				dateBegin: $(".table-search .dateBegin").val(),
				dateEnd: $(".table-search .dateEnd").val(),
				claimNumber: $(".table-search .claimNumber").val(),
				insuranceCompany: $(".table-search .insuranceCompany").val(),
				abnormalState: $(".table-search .abnormalState").val(),
				claimState: $(".table-search .claimState").val(),
				claimProcess: $(".table-search .claimProcess").val(),
			};
			inquireClaimPageList(oData);
		});

		$("#leftMenu9").on("click", ".insurance1", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance2", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance3", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		$("#leftMenu9").on("click", ".insurance4", function() {
			location.href = "../insuranceManage/insuranceManage.html";
		});

		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			location.href = "../login/login.html";
		}

		//详情
		$("#claimManage").on("click", ".detail", function() {

		});

		//报案
		$("#claimManage").on("click", ".createClaimReport", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_report_case);
			dialog.showDialog($("#create_report_case_dialog"));
			tools.requireInput($("#create_report_case_dialog"));
			databind.fillForm($("#create_report_case_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_report_case_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#reportFileUuid"), "claimMaterial");
			});

			$("#create_report_case_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_report_case_dialog"));
			});

			$("#create_report_case_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_report_case_dialog"), function() {
					base.alert(1, "报案信息添加成功！");
					dialog.hideDialog($("#create_report_case_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//材料准备
		$("#claimManage").on("click", ".createClaimMaterial", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_claim_material);
			dialog.showDialog($("#create_claim_material_dialog"));
			tools.requireInput($("#create_claim_material_dialog"));
			databind.fillForm($("#create_claim_material_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_material_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#materialFileUuid"), "claimMaterial");
			});

			$("#create_claim_material_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_material_dialog"));
			});

			$("#create_claim_material_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_material_dialog"), function() {
					base.alert(1, "资料准备成功！");
					dialog.hideDialog($("#create_claim_material_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//报案受理
		$("#claimManage").on("click", ".createClaimAcceptance", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_claim_acceptance);
			dialog.showDialog($("#create_claim_acceptance_dialog"));
			tools.requireInput($("#create_claim_acceptance_dialog"));
			databind.fillForm($("#create_claim_acceptance_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_acceptance_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#acceptanceFileUuid"), "claimMaterial");
			});

			$("#create_claim_acceptance_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_acceptance_dialog"));
			});

			$("#create_claim_acceptance_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_acceptance_dialog"), function() {
					base.alert(1, "报案受理成功！");
					dialog.hideDialog($("#create_claim_acceptance_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//添加调查阶段信息
		$("#claimManage").on("click", ".createClaimSurvey", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_claim_survey);
			dialog.showDialog($("#create_claim_survey_dialog"));
			tools.requireInput($("#create_claim_survey_dialog"));
			databind.fillForm($("#create_claim_survey_dialog"), {
				claimId: claimId
			});

			$("#create_claim_survey_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_survey_dialog"));
			});

			$("#create_claim_survey_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_survey_dialog"), function() {
					base.alert(1, "添加调查阶段信息成功！");
					dialog.hideDialog($("#create_claim_survey_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//添加评估阶段信息
		$("#claimManage").on("click", ".createClaimAssessment", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_claim_assessment);
			dialog.showDialog($("#create_claim_assessment_dialog"));
			tools.requireInput($("#create_claim_assessment_dialog"));
			databind.fillForm($("#create_claim_assessment_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_assessment_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#assessmentFileUuid"), "claimMaterial");
			});

			$("#create_claim_assessment_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_assessment_dialog"));
			});

			$("#create_claim_assessment_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_assessment_dialog"), function() {
					base.alert(1, "添加法院处理信息成功！");
					dialog.hideDialog($("#create_claim_assessment_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//添加法院处理信息
		$("#claimManage").on("click", ".createClaimHandle", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_claim_handle);
			dialog.showDialog($("#create_claim_handle_dialog"));
			tools.requireInput($("#create_claim_handle_dialog"));
			databind.fillForm($("#create_claim_handle_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_handle_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#handleFileUuid"), "claimMaterial");
			});

			$("#create_claim_handle_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_handle_dialog"));
			});

			$("#create_claim_handle_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_handle_dialog"), function() {
					base.alert(1, "添加法院处理信息成功！");
					dialog.hideDialog($("#create_claim_handle_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//添加赔付信息
		$("#claimManage").on("click", ".createClaimSettle", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			var insuranceId = $(this).parents("tr").attr("insuranceId");
			$("#popdialog").html(html_create_settlement);
			dialog.showDialog($("#create_claim_settlement_dialog"));
			tools.requireInput($("#create_claim_settlement_dialog"));
			tools.loadList("inquireInsuranceDetail.json", $("#settlementInsuranceTable"), $("#settlementInsuranceTpl"), {
				insuranceId: insuranceId
			}, function() {

			});
			databind.fillForm($("#create_claim_settlement_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_settlement_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#settlementFileUuid"), "claimMaterial");
			});

			$("#create_claim_settlement_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_settlement_dialog"));
			});

			$("#create_claim_settlement_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_settlement_dialog"), function() {
					base.alert(1, "添加赔付信息成功！");
					dialog.hideDialog($("#create_claim_settlement_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//添加整改信息
		$("#claimManage").on("click", ".createClaimCorrective", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_create_corrective);
			dialog.showDialog($("#create_claim_corrective_dialog"));
			tools.requireInput($("#create_claim_corrective_dialog"));
			databind.fillForm($("#create_claim_corrective_dialog"), {
				claimId: claimId
			});
			//附件添加
			$("#create_claim_corrective_dialog").on("change", "#claimMaterial", function() {
				uploadFile($("#claimMaterial"), $(".claimMaterial"), $("#correctiveFileUuid"), "claimMaterial");
			});

			$("#create_claim_corrective_dialog").on("click", ".sure_no", function() {
				dialog.hideDialog($("#create_claim_corrective_dialog"));
			});

			$("#create_claim_corrective_dialog").on("click", ".sure_yes", function() {
				databind.submitDom($("#create_claim_corrective_dialog"), function() {
					base.alert(1, "添加法院处理信息成功！");
					dialog.hideDialog($("#create_claim_corrective_dialog"));
					router.route("claimManage/claimManage.html");
				});
			});
		});

		//结案
		$("#claimManage").on("click", ".finishClaim", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_finish_claim);
			dialog.showDialog($("#finish_claim_dialog"));
			if ($(this).parents("tr").attr("claimState") == 3) {

			} else {
				tools.requireInput($("#finish_claim_dialog"));
				databind.fillForm($("#finish_claim_dialog"), {
					claimId: claimId
				});

				tools.inquireCommonSelectorList(9, $("#finish_claim_dialog .windupReson"));
				$("#finish_claim_dialog").on("click", ".sure_no", function() {
					dialog.hideDialog($("#finish_claim_dialog"));
				});

				$("#finish_claim_dialog").on("click", ".sure_yes", function() {
					databind.submitDom($("#finish_claim_dialog"), function() {
						base.alert(1, "结案成功！");
						dialog.hideDialog($("#finish_claim_dialog"));
						router.route("claimManage/claimManage.html");
					});
				});
			}
		});

		//销案
		$("#claimManage").on("click", ".closeClaim", function() {
			var claimId = $(this).parents("tr").attr("claimId");
			$("#popdialog").html(html_close_claim);
			tools.inquireCommonSelectorList(9, $("#close_claim_dialog .windupReson"));
			dialog.showDialog($("#close_claim_dialog"));
			var $this = $(this);
			if ($this.parents("tr").attr("claimState") == 2) {
				databind.fillForm($("#close_claim_dialog"), {
					windupReson: $this.parents("tr").attr("windupReson"),
					windupRemark: $this.parents("tr").attr("windupRemark")
				});
				$("#close_claim_dialog .sure_no").remove();
				$("#close_claim_dialog").on("click", ".sure_yes", function() {
					dialog.hideDialog($("#close_claim_dialog"));
				});
			} else {
				tools.requireInput($("#close_claim_dialog"));
				databind.fillForm($("#close_claim_dialog"), {
					claimId: claimId
				});

				$("#close_claim_dialog").on("click", ".sure_no", function() {
					dialog.hideDialog($("#close_claim_dialog"));
				});

				$("#close_claim_dialog").on("click", ".sure_yes", function() {
					databind.submitDom($("#close_claim_dialog"), function() {
						base.alert(1, "销案成功！");
						dialog.hideDialog($("#close_claim_dialog"));
						router.route("claimManage/claimManage.html");
					});
				});
			}
		});


		$("#claimManage").on("click", ".step", function() {
			var $this = $(this);
			var step = $(this).attr("step");
			if ($this.attr("stepDate") == "") {

			} else {
				switch (step) {
					case "step1":
						$("#popdialog").html(html_claim_report_case_list);
						dialog.showDialog($("#report_case_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#reportCaseListTable"), $("#reportCaseListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$("#report_case_list_dialog .sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#report_case_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_report_case);
								dialog.showDialog($("#create_report_case_dialog"));
								databind.fillInput($("#create_report_case_dialog"), {
									action: "inquireClaimReportCase.json?reportCaseId=" + $(this).parents("tr").attr("reportcaseId"),
									async: false
								});
								databind.disableInput($("#create_report_case_dialog"));
								var fileUuid = $("#reportFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_report_case_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_report_case_dialog"));
								});
							});
						});
						break;
					case "step2":
						$("#popdialog").html(html_claim_material_list);
						dialog.showDialog($("#claim_material_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimMaterialListTable"), $("#claimMaterialListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_material_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_claim_material);
								dialog.showDialog($("#create_claim_material_dialog"));
								databind.fillInput($("#create_claim_material_dialog"), {
									action: "inquireClaimMaterial.json?claimMaterialId=" + $(this).parents("tr").attr("claimMaterialId"),
									async: false
								});
								databind.disableInput($("#create_claim_material_dialog"));
								var fileUuid = $("#materialFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_claim_material_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_material_dialog"));
								});
							});
						});
						break;
					case "step3":
						$("#popdialog").html(html_claim_acceptance_list);
						dialog.showDialog($("#claim_acceptance_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimAcceptanceListTable"), $("#claimAcceptanceListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_acceptance_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_claim_acceptance);
								dialog.showDialog($("#create_claim_acceptance_dialog"));
								databind.fillInput($("#create_claim_acceptance_dialog"), {
									action: "inquireClaimAcceptance.json?claimAcceptanceId=" + $(this).parents("tr").attr("claimAcceptanceId"),
									async: false
								});
								databind.disableInput($("#create_claim_acceptance_dialog"));
								var fileUuid = $("#acceptanceFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_claim_acceptance_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_acceptance_dialog"));
								});
							});
						});
						break;
					case "step4":
						$("#popdialog").html(html_claim_survey_list);
						dialog.showDialog($("#claim_survey_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimSurveyListTable"), $("#claimSurveyListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_survey_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_claim_survey);
								dialog.showDialog($("#create_claim_survey_dialog"));
								databind.fillInput($("#create_claim_survey_dialog"), {
									action: "inquireClaimSurvey.json?claimSurveyId=" + $(this).parents("tr").attr("claimSurveyId"),
									async: false
								});
								databind.disableInput($("#create_claim_survey_dialog"));
								$(".sure_no").remove();

								$("#create_claim_survey_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_acceptance_dialog"));
								});
							});
						});
						break;
					case "step5":
						$("#popdialog").html(html_claim_assessment_list);
						dialog.showDialog($("#claim_assessment_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimAssessmentListTable"), $("#claimAssessmentListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_assessment_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_claim_assessment);
								dialog.showDialog($("#create_claim_assessment_dialog"));
								databind.fillInput($("#create_claim_assessment_dialog"), {
									action: "inquireClaimAssessment.json?claimAssessmentId=" + $(this).parents("tr").attr("claimAssessmentId"),
									async: false
								});
								databind.disableInput($("#create_claim_assessment_dialog"));
								var fileUuid = $("#assessmentFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_claim_assessment_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_assessment_dialog"));
								});
							});
						});
						break;
					case "step6":
						$("#popdialog").html(html_claim_handle_list);
						dialog.showDialog($("#claim_handle_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimHadleListTable"), $("#claimHadleListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_handle_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_claim_handle);
								dialog.showDialog($("#create_claim_handle_dialog"));
								databind.fillInput($("#create_claim_handle_dialog"), {
									action: "inquireClaimHandle.json?claimHandleId=" + $(this).parents("tr").attr("claimHandleId"),
									async: false
								});
								databind.disableInput($("#create_claim_handle_dialog"));
								var fileUuid = $("#handleFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_claim_handle_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_handle_dialog"));
								});
							});
						});
						break;
					case "step7":
						$("#popdialog").html(html_claim_settlement_list);
						dialog.showDialog($("#claim_settlement_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimSettlementListTable"), $("#claimSettlementListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_settlement_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_settlement_detail);
								dialog.showDialog($("#claim_settlement_detail_dialog"));
								tools.loadList("inquireClaimSettlement.json", $("#settlementDetailTable"), $("#settlementDetailTpl"), {
									claimSettlementId: $(this).parents("tr").attr("claimSettlementId")
								}, function() {

								});
								databind.fillInput($("#claim_settlement_detail_dialog"), {
									action: "inquireClaimSettlement.json?claimSettlementId=" + $(this).parents("tr").attr("claimSettlementId"),
									async: false
								});
								databind.disableInput($("#claim_settlement_detail_dialog"));
								var fileUuid = $("#settlementFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#claim_settlement_detail_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#claim_settlement_detail_dialog"));
								});
							});
						});
						break;
					case "step8":
						$("#popdialog").html(html_claim_corrective_list);
						dialog.showDialog($("#claim_corrective_list_dialog"));
						tools.loadList("inquireClaimDetail.json", $("#claimCorrectiveListTable"), $("#claimCorrectiveListTpl"), {
							claimId: $this.parents("tr").attr("claimId")
						}, function() {
							$(".sure_yes").unbind("click").click(function() {
								dialog.hideDialog($("#claim_corrective_list_dialog"));
							});

							$(".detail").unbind("click").click(function() {
								$("#popdialog1").html(html_create_corrective);
								dialog.showDialog($("#create_claim_corrective_dialog"));
								databind.fillInput($("#create_claim_corrective_dialog"), {
									action: "inquireClaimCorrective.json?claimCorrectiveId=" + $(this).parents("tr").attr("claimCorrectiveId"),
									async: false
								});
								databind.disableInput($("#create_claim_corrective_dialog"));
								var fileUuid = $("#correctiveFileUuid").val();
								$(".claimMaterial").html("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + fileUuid + "'>附件</a>").attr("for", "");
								$(".sure_no").remove();

								$("#create_claim_corrective_dialog .sure_yes").unbind("click").click(function() {
									dialog.hideDialog($("#create_claim_corrective_dialog"));
								});
							});
						});
						break;
					default:
						break;
				}
			}
		});
	};

	var inquireClaimPageList = function(oData) {
		tools.loadList("inquireClaimPageList.json", $("#claimManageBody"), $("#claimManageTpl"), oData, function() {
			$(".abnormalDetail").unbind("click").click(function() {
				router.route("exception/exceptionDetailInfo.html?abnormalId=" + $(this).attr("abnormalId"));
			});

			$.each($(".claimData"), function() {
				//				var claimProcess = $(this).attr("claimProcess");
				//				claimProcess = 9;
				var claimProcess;
				var steps = $(this).find(".step");
				var dateTime;

				$.each(steps, function(n, v) {
					if ($(v).attr("stepDate") != "") {
						claimProcess = n + 2;
						dateTime = $(v).attr("stepDate");
					}
				});
				var d;
				if (dateTime != null) {
					d = tools.timeCalculator(new Date(dateTime.replace(/-/g, "/")), new Date()) / 360000;
				}
				if (claimProcess == undefined) {
					$(steps[0]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
				} else if (claimProcess == 2) {
					if (d < 6) {
						$(steps[1]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[1]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 3) {
					if (d < 6) {
						$(steps[2]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[2]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 4) {
					if (d < 6) {
						$(steps[3]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[3]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 5) {
					if (d < 6) {
						$(steps[4]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[4]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 6) {
					if (d < 6) {
						$(steps[5]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[5]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 7) {
					if (d < 6) {
						$(steps[6]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[6]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					$(steps[6]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 8) {
					if (d < 6) {
						$(steps[7]).css("background", "url(../../../res/png/step_processing.jpg) no-repeat center left");
					} else {
						$(steps[7]).css("background", "url(../../../res/png/step_processing_red.jpg) no-repeat center left");
					}
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
				} else if (claimProcess == 9) {
					for (var j = 0; j < claimProcess - 1; j++) {
						if ($(steps[j]).attr("stepDate") != "") {
							$(steps[j]).css("background", "url(../../../res/png/step.jpg) no-repeat center left");
						} else {
							$(steps[j]).css("background", "url(../../../res/png/step_empty.jpg) no-repeat center left");
						}
					}
					if ($(steps[7]).attr("setpDate") != "") {
						$(steps[7]).css("background", "url(../../../res/png/step_last.jpg) no-repeat center left");
					} else {
						$(steps[7]).css("background", "url(../../../res/png/step_empty_last.jpg) no-repeat center left");
					}
				}
			});
		});
	}

	//上传文件
	var uploadFile = function(dom, labelDom, valueDom, fileElementId) {
		if ($(dom).val() != "") {
			$.ajaxFileUpload({
				url: "/finance/api/v1.0/uploadFile.json", //你处理上传文件的服务端
				secureuri: false,
				fileElementId: "claimMaterial",
				dataType: 'json',
				success: function(data) {
					$(valueDom).val(data.data[0].fileUuid);
					$(labelDom).html(data.data[0].fileName);
				},
				complete: function(xml) {
					$(dom).change(function() {
						uploadFile(dom, labelDom, fileElementId);
					});
				},
				error: function(data, status, e) {
					if (data.msg == null) {
						base.alert(2, "文件太大无法上传");
					} else {
						base.alert(2, data.msg);
					}
				}
			});
		} else {
			base.alert(3, "请选择文件！");
		}
	};

	return {
		init: init
	};
});